home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindspring.com!usenet
- From: rudd@mindspring.com (Justin Rudd)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Shortcomings ?
- Date: Fri, 15 Mar 1996 17:32:09 GMT
- Organization: MindSpring Enterprises
- Message-ID: <4ic9kj$lj6@B1FF.mindspring.com>
- References: <31488E8D.167E@aw.sgi.com> <4iaqch$moh@B1FF.mindspring.com> <31493CDA.41C6@aw.sgi.com>
- Reply-To: rudd@mindspring.com
- NNTP-Posting-Host: rudd.mindspring.com
- X-Newsreader: Forte Free Agent v0.55
-
- OK...this clears it up a bit.
-
- Justin
-
- >No.
-
- >I guess my post was messy and unclear.
- >What I want is to be able for a class A to tell:
-
-
- >class A
- >{
- >restricted B:
- > void DoSomething();
- >}
-
- >This means: Ok, the method A::DoSomething is public, but not
- >public for everybody. Only members of class B can have access to
- >this method.
-
- >It's a bit like the friend operator, but instead of spilling
- >everything to the friend, we just let him peep through a specialized window.
-
-
- >No.
-
- >What I meant was: I would like to be able to redefine the default
- >copy constructor for pointers.
-
- >In other words, when I write:
- >class A
- >{
- >};
-
- >main()
- >{
- > A *a;
- > B *b;
-
- > a=new A();
- > b=a;
- >}
-
- >I want the compiler to trap this for me and give me control.
- >What I really want the compiler to do is:
-
- >main()
- >{
- > 1. Call the constructor of object A* (that's what we do. We build an A*)
- > 2. Call the constructor of object B*
-
- > Call the constructor for object A* (to temporarily store the result of new)
- > Call the assignment method (to assign the result of new to a)
- > Call the assignment operator (to assign the value of a to b)
- >
- >}
-
- >Another way to put it:
- >I would like to be able to write
-
- >class A*
- >{
- > A*(); // To build a pointer to A
- > A*(const A*&) // To build an A* from another A*
- > ~A*(); // To get hold of what happens when a pointer to A goes out of scope
-
- > A* operator=(const A*&); // To redefine assignment
- >
- >}
-
-
- >All this complicated mechanics would allow to build
- >industrial-strength reference counting on objects.
-
- > - Mgix
-
-
-